public class Solution01 {
	public TreeNode invertTree(TreeNode root) {
		if (root != null) {
			if (root.left != null && root.right != null) {
				TreeNode temp = root.left;
				root.left = root.right;
				root.right = temp;
			} else if (root.left != null) {
				root.right = root.left;
				root.left = null;
			} else if (root.right != null) {
				root.left = root.right;
				root.right = null;
			}
			invertTree(root.left);
			invertTree(root.right);
		}

		return root;
	}
}
